<template>
  <Spin :spinning="loading" tip="Loading...">
  <div>
    <!-- table -->
    <BaseDialog :visible.sync="isvideo" :title="'视频预览'" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <videos @close="dealercloseHandler" :src="src"/>
    </BaseDialog>
    <BaseDialog :title="'上传附件'" :visible.sync="upVisible" destroyOnClose>
      <uploadFile :rowData="uploadDate" @close="upVisible = false" @save="saveFile"></uploadFile>
    </BaseDialog>
    <BreakSpace label="工单及车辆信息" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel ref="formPanel1" :list="formList" :cols="4" :formType="'add'" labelWidth="110" :isSubmitBtn="false" @formChange="formChangeHandle1" />
    <BreakSpace label="索赔信息" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel ref="formPanel2" :list="formList1" :cols="4" :formType="'add'" labelWidth="130" :isSubmitBtn="false" @formChange="formChangeHandle2"/>
    <BreakSpace label="上传视频/压缩文件" :containerStyle="{ marginBottom: '10px' }" />
<!--    <UploadFile action-url="/api/file/oss/upload" :initial-value="form.fileList" :fileTypes="['mp4','avi','rmvb','WMV']" :fileSize="100" :isOnlyButton="true"  :limit="10000" @change="successHandler">上传附件</UploadFile>-->
    <FilterTable
      ref="fileTable"
      :columns="columnsFile"
      columnsRef="whbydUploadFile"
      :isSelectColumn="false"
      :onColumnsChange="columnsFile => (this.columnsFile = columnsFile)"
      height=auto
      :dataSource="list"
    />
    <BreakSpace label="维修项目列表" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable
      ref="table"
      :columns="columns"
      :params="fetchParams"
      :dataSource="dataList"
      :datakey="'items'"
      :onColumnsChange="columns => (this.columns = columns)"
      :onRowSelectChange="selectChange"
      :onCellChange="changeCells"
      :isSelectColumn="false"
      :isPagination="false"
      height="auto"
    >
    </FilterTable>
    <div style="margin-bottom: 1rem;"></div>
    <BreakSpace label="配件换上件列表" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable
      ref="table1"
      :columns="columns1"
      :params="fetchParams"
      :dataSource="dataList1"
      :datakey="'items'"
      :onColumnsChange="columns1 => (this.columns1 = columns1)"
      :onRowSelectChange="selectChange"
      :onCellChange="changeCells1"
      :isSelectColumn="false"
      :isPagination="false"
      height="auto"
    >
    </FilterTable>
    <BreakSpace label="配件换下件列表" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable
      ref="table2"
      :columns="downFile"
      :params="fetchParams"
      :dataSource="huanxiajiandataList"
      :datakey="'items'"
      :onColumnsChange="downFile => (this.downFile = downFile)"
      :onRowSelectChange="selectChange"
      :isSelectColumn="false"
      :isPagination="false"
      height="auto"
    >
    </FilterTable>
    <BreakSpace label="附加项目列表" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable
      ref="table3"
      :columns="addList"
      :params="fetchParams"
      :dataSource="fujiaxiangmudataList"
      :datakey="'items'"
      :onColumnsChange="addList => (this.addList = addList)"
      :onRowSelectChange="selectChange"
      :onCellChange="changeCells3"
      :isSelectColumn="false"
      :isPagination="false"
      height="auto"
    >
    </FilterTable>
    <Drawer :visible.sync="actions.visible" :title="actions.title" width="70%" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <addDialog :type="actions.type" :row="formData" @close="close" />
    </Drawer>
<!--    <BreakSpace label="审核备注" :containerStyle="{ marginBottom: '10px' }" />-->
    <FormPanel ref="formPanelbeizhu" :list="formListbeizhu" :cols="1" :formType="'add'" labelWidth="110" :isSubmitBtn="false" />
    <BreakSpace label="申请费用信息" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel ref="formPanel3" :list="MoneyList" :cols="4" :formType="'add'" labelWidth="110" :isSubmitBtn="false" @formChange="formChangeHandle3"/>
    <BreakSpace label="审核费用信息" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel ref="formPanel4" :list="auditList" :cols="4" :formType="'add'" labelWidth="110" :isSubmitBtn="false"@formChange="formChangeHandle4" />
    <LazyLoadTab v-model="activeName" :tabMenus="menus"></LazyLoadTab>
    <div style="padding-top: 3rem;"></div>
    <div
      :style="{
        position: 'fixed',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <multiuse-button type="primary" :click="saveDialog.bind()" :disabled="this.rowData.changeFlag==0?true:false">保 存</multiuse-button>
      <multiuse-button type="primary" @click="closeDialog">关 闭</multiuse-button>
    </div>
  </div>
  </Spin>
</template>
<script>
import { saveRescue, getResultList } from '@/api/repair/repairBusiness/rescueService/index';
import addDialog from '@/pages/claimDemage/BasicData/ClaimApplication/addDialog.vue';
import { getToken, getUserId, getOwnerCode, removeDataType, getAppId, removeAppId } from '@/assets/js/auth';
import { quyrPCmsClaim,editSave}  from '@/api/claim/factory/ClaimExpensesChange/index';
import { isFormEmpty } from '@/utils/index';
import { getPartType,getClaim } from '@/api/dictionary/index';
import { getRoById } from '@/api/claim/dealer/ClaimApplication/index';
import { copyUpdateData } from '@/utils/index';
import moment from "moment";
import selectDelearPage from "../ClaimCheck/selectDelearPage";
import videos from '@/pages/claimDemage/BasicData/AuthApplication/videos.vue'
import uploadFile from "../ClaimQueryDealer/uploadFile";
import { dictionary } from '@/utils/dictMixin';
  export default {
    components: {
      addDialog,videos, uploadFile
    },
  mixins: [dictionary],
  props: [ 'rowData'],
  data() {
    return {
      uploadDate: {},
      upVisible: false,
      form: {
        fileList: []
      },
      src:null,
      list: [],
      isvideo:false,
      syncList: [],
      columnsFile: this.createdTable(),
      actions: { type: 'add', title: '', visible: false, data: null },
      formData: {},
      loading: false,
      saveData1: null,
      saveData2: null,
      saveData3: null,
      saveData4: null,
      dataList: [],
      dataList1: [],
      huanxiajiandataList: [],
      fujiaxiangmudataList: [],
      visible: false,
      flterValue: {}, //参数
      columns: this.creatHeader(),
      columns1: this.creatHeader1(),
      downFile: this.columnshuanxiajian1(),
      addList: this.columnsfujiaxiangmu1(),
      formListbeizhu: this.formListbeizhuform(),
      fetchParams: {}, //ipa 接口
      selectedRows: [], //选中经销商
      formList: this.createFormList(),
      formList1: this.createFormList1(),
      MoneyList: this.feiyongformList1(),
      auditList: this.shenhefeiyongformList1(),
      editRow: {},
      saveData: {},
      activeName: '审核记录',
      menus: [
        {
          title: '审核记录',
          path: 'claimDemage/BasicData/ClaimExpensesChange/jiluandlishi/shenhejilu',
          params: {
            claimId: this.rowData.claimId
          }
        },
        {
          title: '维修历史',
          path: 'claimDemage/BasicData/ClaimExpensesChange/jiluandlishi/weixiulishi',
          params: {
            roNo: this.rowData.roNo
          },
          disabled: true,
        },
        {
          title: '索赔历史',
          path: 'claimDemage/BasicData/ClaimExpensesChange/jiluandlishi/suopeilishi',
          params: {
            roNo: this.rowData.roNo
          },
          disabled: true,
        }
      ]
    };
  },
    async created() {
      this.loading = true;
      await this.chuqi();
      await this.getrPCmsClaim(this.rowData.claimId);
      // await this.getListByPageWork(this.rowData.roNo);
      this.loading = false;
    },

  mounted() {
  },
  methods: {
    dealercloseHandler(){
      this.isvideo = false;
    },
    // 上传成功回调
    successHandler(val) {
      let json = JSON.parse(JSON.stringify(val));
      let data = {};
      data.createdAt = moment().format('YYYY-MM-DD HH:mm:ss');
      data.title = json[json.length - 1].name;
      data.fileUrl = json[json.length - 1].url;
      this.$refs.fileTable.$refs.pageTable.EXECUTE_INSERT(data);
    },
    video(val){
      this.isvideo = true;
      this.src = val.fileUrl;
    },
    delVideo(val){
      console.log("#@!#!",val)
      this.$refs.fileTable.$refs.pageTable.EXECUTE_DELETE([val]);
    },
    async chuqi(){
      console.log("进来了")

      // const res1 = await getPartType( {type:5513});
      // if (res1.resultCode == 200) {
      //   this.formList.find(x => x.fieldName == 'claimStatus').initialValue = '';
      //   this.formList.find(x => x.fieldName == 'claimStatus').itemList = res1.data.map(y => ({ text: y.codeCnDesc, value: y.codeId }));
      // }
      const res2 = await getClaim();
      if (res2.resultCode == 200) {
        this.formList1.find(x => x.fieldName == 'cmsClaimType').initialValue = '';
        this.formList1.find(x => x.fieldName == 'cmsClaimType').itemList = res2.data.map(y => ({ text: y.name, value: y.code }));
      }
      // const res3 = await getPartType( {type:5543});
      // if (res3.resultCode == 200) {
      //   this.formList1.find(x => x.fieldName == 'ifComm').initialValue = '';
      //   this.formList1.find(x => x.fieldName == 'ifComm').itemList = res3.data.map(y => ({ text: y.codeCnDesc, value: y.codeId }));
      // }
      // const res5 = await getPartType( {type:5585});
      // this.downFile.find((x) => x.dataIndex === 'returnType').dictItems = res5.data.map((x) => ({
      //   value: x.codeId + '',
      //   text: x.codeCnDesc,
      // }));
    },
    async getListByPageWork(roNo) {
      let res = await getRoById({roNo: roNo});
      let data = res.data;
      for (let i in data) {
        this.formList.map(y => {
          if (i == y.fieldName) {
            y.initialValue = data[i];
          }
        });
      }
    },
    close() {
        // 关闭
        this.actions.visible = false;
      },
    //页面数据装载
    async getrPCmsClaim(val){
   let res= await quyrPCmsClaim(val);
      this.editRow = res.data;
      let data = res.data;
      this.rescueNo = data.outNo;
      this.ownerCode = data.ownerCode;
      if(res.data.priceAmount!=null){
        this.columns.find(x => x.dataIndex == 'checkAmount').editable = false;
        this.columns1.find(x => x.dataIndex == 'checkAmount').editable = false;
        this.addList.find(x => x.dataIndex == 'checkAmount').editable = false;
      }
      if(data.saleDate){
        data.saleDate = moment(data.saleDate).format('YYYY-MM-DD');
      }
      if(data.prodDate){
        data.prodDate = moment(data.prodDate).format('YYYY-MM-DD');
      }
      if(data.repairBeginDate){
        data.repairBeginDate = moment(data.repairBeginDate).format('YYYY-MM-DD');
      }
      //为3个form赋值
      for (let i in data.fileList) {
        if(data.fileList[i].type==55141001) {
          this.formList1.find(x => x.fieldName == 'wayPicture').initialValue =  [{url : data.fileList[i].fileUrl,name : data.fileList[i].title}];
        }else if(data.fileList[i].type==55141002) {
          this.formList1.find(x => x.fieldName == 'wayPicture1').initialValue = [{url : data.fileList[i].fileUrl,name : data.fileList[i].title}];
        }else if(data.fileList[i].type==55141003) {
          this.formList1.find(x => x.fieldName == 'wayPicture2').initialValue = [{url : data.fileList[i].fileUrl,name : data.fileList[i].title}];
        }else if(data.fileList[i].type==55141004) {
          this.formList1.find(x => x.fieldName == 'wayPicture3').initialValue = [{url : data.fileList[i].fileUrl,name : data.fileList[i].title}];
        }else if(data.fileList[i].type==55141005) {
          this.formList1.find(x => x.fieldName == 'wayPicture4').initialValue = [{url : data.fileList[i].fileUrl,name : data.fileList[i].title}];
        }else if(data.fileList[i].type==55141006) {
          this.formList1.find(x => x.fieldName == 'wayPicture5').initialValue = [{url : data.fileList[i].fileUrl,name : data.fileList[i].title}];
        }

      }
      //为table赋值
      let newFile = [];
      for(let i in data.fileList){
        if(data.fileList[i].type==null){
          newFile.push(res.data.fileList[i])
        }
      }
      this.$refs.fileTable.$refs.pageTable.EXECUTE_INSERT(newFile);
      for (let i in data) {
        this.formList.map(y => {
          if (i == y.fieldName) {
            y.initialValue = data[i];
          }
        });
        this.formList1.map(y => {
          if (i == y.fieldName) {
            y.initialValue = data[i];
          }
        });
        this.MoneyList.map(y => {
          if (i == y.fieldName) {
            y.initialValue = data[i];
          }
        });
        this.auditList.map(y => {
          if (i == y.fieldName) {
            y.initialValue = data[i];
          }
        });
      }
      //为table赋值
      if (200 == res.resultCode) {
        let data = res.data;
        if (isFormEmpty(data)) {
          data = {};
        }
        let records = data.labourList;
        if (isFormEmpty(records)) {
          records = [];
        }
        // 维修项目列表
        this.$refs.table.$refs.pageTable.EXECUTE_INSERT(records);


        let records1 = data.addList;
        if (isFormEmpty(records1)) {
          records1 = [];
        }
        //附加项目列表
        this.$refs.table3.$refs.pageTable.EXECUTE_INSERT(records1);
      }
      let records2 = data.partList;
      if (isFormEmpty(records2)) {
        records2 = [];
      }
      //配件换下件列表
      this.$refs.table2.$refs.pageTable.EXECUTE_INSERT(records2);

      let records3 = data.partRList;
      if (isFormEmpty(records3)) {
        records3 = [];
      }
      //配件换上件列表
      this.$refs.table1.$refs.pageTable.EXECUTE_INSERT(records3);
      console.info(res);
      this.newVar = data
    },
    formChangeHandle1(val) {
      console.log(val);
      this.saveData1 = val;
    },
    formChangeHandle2(val) {
      console.log(val);
      this.saveData2 = val;
    },
    formChangeHandle3(val) {
      console.log(val);
      this.saveData3 = val;
    }, formChangeHandle4(val) {
      console.log(val);
      this.saveData4 = val;
    },
    //搜索获取数据
    changeHandle(val) {
      this.fetchParams = Object.assign({}, this.fetchParams, val);
      console.log(val);
    },
    //选中
    selectChange(rows) {
      this.selectedRows = rows;
      console.log(this.selectedRows);
    },

    //修改后的保存
    async saveDialog() {
      //form值生效
      this.$refs.formPanel1.SUBMIT_FORM();
      this.$refs.formPanel2.SUBMIT_FORM();
      this.$refs.formPanel3.SUBMIT_FORM();
      this.$refs.formPanel4.SUBMIT_FORM();
      //取出4个table值
      let arr = [];
      this.$refs.table.$refs.pageTable.list.map(x => {
        arr.push(x);
      });

      let arr1 = [];
      this.$refs.table1.$refs.pageTable.list.map(x => {
        arr1.push(x);
      });


      let arr2 = [];
      this.$refs.table2.$refs.pageTable.list.map(x => {
        arr2.push(x);
      });//下件
      console.log(arr2);

      let arr3 = [];
      this.$refs.table3.$refs.pageTable.list.map(x => {
        arr3.push(x);
      });
      //附加
      console.log(arr3);

      //维修项目
      this.saveData.labourList = arr;
      console.log( 666666);
      console.log( this.saveData.labourList);

      //换上件
      this.saveData.partRList = arr1;
      //换下件
      this.saveData.partList = arr2;
      //附加项目
      this.saveData.addList = arr3;

      this.saveData = Object.assign(this.saveData, this.saveData1);

      this.saveData = Object.assign(this.saveData, this.saveData2);

      this.saveData = Object.assign(this.saveData, this.saveData3);

      this.saveData = Object.assign(this.saveData, this.saveData4);

      this.saveData.saleDate = moment(this.saveData.saleDate).format('YYYY-MM-DD HH:mm:ss');
      //保修起始日期
      this.saveData.repairBeginDate = moment(this.saveData.repairBeginDate).format('YYYY-MM-DD HH:mm:ss');
      //维修开始时间
      this.saveData.serviceBeginDate = moment(this.saveData.serviceBeginDate).format('YYYY-MM-DD HH:mm:ss');
      //维修结束时间
      this.saveData.serviceEndDate = moment(this.saveData.serviceEndDate).format('YYYY-MM-DD HH:mm:ss');
      //自费配件销售日期
      // this.saveData.selfSdate = moment(this.saveData.selfSdate).format('YYYY-MM-DD HH:mm:ss');
      //生产日期
      this.saveData.prodDate = moment(this.saveData.prodDate).format('YYYY-MM-DD HH:mm:ss');

      this.newVar = copyUpdateData(this.newVar,this.saveData);

      this.loading = true;
      //编辑的保存
      let res = await editSave(this.newVar);

      if (res.resultCode === 200) {
        this.$emit('save');
        return this.$notify.success({ title: '提示信息', message: '保存成功' });

      } else {
        this.loading = false;
        this.$notify.error({ title: '提示信息', message: res.errMsg || '保存失败!' });
        this.closeDialog();
      }

    },
    //取消操作
    closeDialog() {
      this.$emit('close', { visible: false, data: this.selectedRows, type: 'close' });
    },
    chooseOrderNo() {
      this.visible = true;
    },
    async changeCells(keys, obj) {
      let sumweixiufeiyong = 0;
      this.$refs.table.$refs.pageTable.list.map(x => {
        sumweixiufeiyong += Number(x.checkAmount);
      });
      this.auditList.map(x => {
        if ('claimLabourAmount' == x.fieldName) {
          x.initialValue = Number(sumweixiufeiyong);
        }
      });
      this.sumAmount();
    },
    async detail(){
      if(this.rescueNo){
        this.formData.rescueNo = this.rescueNo;
        this.formData.ownerCode = this.ownerCode;
        const res  = await getResultList({rescueNo:this.rescueNo,ownerCode:this.ownerCode});
        let val = res.data.rows[0]
        this.formData = val;
        this.actions = { type: 'edit', visible: true, title: '外出救援' };
      }else{
        this.$notify.error({title: '提示信息', message:  '请选择救援单号'});
      }
    },
    async changeCells1(keys, obj) {
      let sumweixiufeiyong = 0;
      this.$refs.table1.$refs.pageTable.list.map(x => {
        sumweixiufeiyong += Number(x.checkAmount);
      });
      this.auditList.map(x => {
        if ('claimPartAmount' == x.fieldName) {
          x.initialValue = Number(sumweixiufeiyong);
        }
      });
      this.sumAmount();
    },
    async changeCells3(keys, obj) {
      let sumweixiufeiyong = 0;
      this.$refs.table3.$refs.pageTable.list.map(x => {
        sumweixiufeiyong += Number(x.checkAmount);
      });
      this.auditList.map(x => {
        if ('claimAddAmount' == x.fieldName) {
          x.initialValue = Number(sumweixiufeiyong);
        }
      });
      this.sumAmount();
    },
    sumAmount() {
      let sum = 0;
      this.$refs.table.$refs.pageTable.list.map(x => {
        sum += Number(x.checkAmount);
      });
      this.$refs.table1.$refs.pageTable.list.map(x => {
        sum += Number(x.checkAmount);
      });
      this.$refs.table3.$refs.pageTable.list.map(x => {
        sum += Number(x.checkAmount);
      });
      sum  += this.MoneyList.find(x => x.fieldName == 'helpAmount').initialValue;
      let realVal = parseFloat(sum).toFixed(2);
      this.auditList.map(x => {
        if('claimSumAmount' == x.fieldName) {
          x.initialValue = realVal;
        }
      });
    },
    saveFile(obj){
      let list = this.$refs.table3.$refs.pageTable.list;
      list.find(x => x.addCode == obj.addCode).addFiles = obj.length==0 ? []:obj;
      this.upVisible = false;
    },
    editFile(row){
      this.upVisible = true;
      this.uploadDate = row;
      this.uploadDate.claimId = this.rowData.claimId;
    },
    add() {},
    createFormList() {
      return [
        {
          type: 'INPUT',
          label: '经销商代码',
          fieldName: 'ownerCode',
          placeholder: '请输入标题名称...',
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '经销商名称',
          fieldName: 'ownerName',
          placeholder: '请输入标题名称...',
          disabled: true,
        },
        {
          type: 'SELECT',
          label: '索赔单状态:',
          fieldName: 'claimStatus',
          placeholder: '请输入标题名称...',
          disabled: true,
          itemList: this.createDictList('5513')
        },
        {
          type: 'INPUT',
          label: 'VIN',
          fieldName: 'vin',
          initialValue: '',
          placeholder: '请输入VIN...',
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '索赔单号',
          fieldName: 'claimNo',
          placeholder: '请输入标题名称...',
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '维修工单号',
          fieldName: 'roNo',
          placeholder: '请输入标题名称...',
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '销售日期',
          fieldName: 'saleDate',
          placeholder: '请输入标题名称...',
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '保修起始日期',
          fieldName: 'repairBeginDate',
          placeholder: '请输入标题名称...',
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '车牌号',
          fieldName: 'licenseNo',
          placeholder: '请输入标题名称...',
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '车型名称',
          fieldName: 'modelName',
          placeholder: '请输入标题名称...',
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '生产日期',
          fieldName: 'prodDate',
          placeholder: '请输入标题名称...',
          disabled: true,
        },

        {
          type: 'INPUT',
          label: '行驶里程',
          fieldName: 'driveMile',
          placeholder: '请输入标题名称...',
          disabled: true,
        },
        {
          type: 'DATE',
          label: '维修开始时间',
          fieldName: 'serviceBeginDate',
          placeholder: '请输入标题名称...',
          disabled: true,
        },
        {
          type: 'DATE',
          label: '维修结束时间',
          fieldName: 'serviceEndDate',
          placeholder: '请输入标题名称...',
          disabled: true,
        },
        // {
        //   type: 'INPUT',
        //   label: '是否特殊车辆',
        //   fieldName: 'isSpecial',
        //   placeholder: '请输入标题名称...',
        //   disabled: true,
        // },
        {
          type: 'INPUT',
          label: '车主姓名',
          fieldName: 'customerName',
          placeholder: '请输入标题名称...',
          disabled: true,
          readonly: true, // 只读
        }

      ];
    },
    createFormList1() {
      return [
        { type: 'SELECT', label: '索赔类型', fieldName: 'cmsClaimType', placeholder: '请选择', initialValue: '', itemList: [],disabled: true },
        {
          type: 'INPUT',
          label: '预授权单号',
          fieldName: 'authNo',
          placeholder: '请输入数量...',
          readonly: true,
          disabled: true,
          // unitRender: p => {
          //   return (
          //     <div>
          //     <multiuse-button icon="el-icon-search" onClick={() => this.selectYsqCode()} />
          //   </div>
          // );
          // }
        },
        {
          type: 'INPUT',
          label: '批量活动编号',
          fieldName: 'batchCode',
          placeholder: '请输入数量...',
          initialValue: undefined,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '批量活动名称',
          fieldName: 'batchName',
          placeholder: '请输入数量...',
          initialValue: undefined,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '主损件',
          fieldName: 'partCode',
          placeholder: '请输入数量...',
          readonly: true,
          disabled: true,
          // unitRender: p => {
          //   return (
          //     <div>
          //     <multiuse-button icon="el-icon-search" onClick={() => this.selectpartCode()} />
          //   </div>
          // );
          // }
        },
        {
          type: 'INPUT',
          label: '主损件名称',
          fieldName: 'partName',
          placeholder: '请输入数量...',
          initialValue: undefined,
          disabled: true,
        },
        { type: 'SELECT', label: '供应商', fieldName: 'supName', placeholder: '请选择', initialValue: '', itemList: [] ,disabled: true,},
        { type: 'SELECT', label: '车辆属性', fieldName: 'ifComm', placeholder: '请选择', initialValue: '', itemList:this.createDictList('5543') ,disabled: true,},
        {
          type: 'INPUT',
          label: '故障现象代码',
          fieldName: 'faultCode',
          placeholder: '请输入数量...',
          readonly: true,
          initialValue: undefined,
          disabled: true,
          // unitRender: p => {
          //   return (
          //     <div>
          //     <multiuse-button icon="el-icon-search" onClick={() => this.selectfaultCode()} />
          //   </div>
          // );
          // }
        },
        {
          type: 'INPUT',
          label: '故障现象描述',
          fieldName: 'faultName',
          placeholder: '请输入数量...',
          initialValue: undefined,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '一级代码',
          fieldName: 'sysCode1',
          placeholder: '请输入数量...',
          initialValue: undefined,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '一级名称',
          fieldName: 'sysName1',
          placeholder: '请输入数量...',
          initialValue: undefined,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '二级代码',
          fieldName: 'sysCode2',
          placeholder: '请输入数量...',
          initialValue: undefined,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '二级名称',
          fieldName: 'sysName2',
          placeholder: '请输入数量...',
          initialValue: undefined,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '三级代码',
          fieldName: 'sysCode3',
          placeholder: '请输入数量...',
          initialValue: undefined,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '三级名称',
          fieldName: 'sysName3',
          placeholder: '请输入数量...',
          initialValue: undefined,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '故障代码',
          fieldName: 'sysCode4',
          placeholder: '请输入数量...',
          initialValue: undefined,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '故障描述',
          fieldName: 'sysName4',
          placeholder: '请输入数量...',
          initialValue: undefined,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '故障原因代码',
          fieldName: 'frCode',
          placeholder: '请输入数量...',
          initialValue: undefined,
          disabled: true,
          readonly: true,
          // unitRender: p => {
          //   return (
          //     <div>
          //     <multiuse-button icon="el-icon-search" onClick={() => this.selectfaultReason()} />
          //   </div>
          // );
          // }
        },
        {
          type: 'INPUT',
          label: '故障原因描述',
          fieldName: 'frName',
          placeholder: '请输入数量...',
          initialValue: undefined,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '质量报告单号',
          fieldName: 'reportNo',
          placeholder: '请输入数量...',
          initialValue: undefined,
          readonly: true,
          disabled: true,
          // unitRender: p => {
          //   return (
          //     <div>
          //     <multiuse-button icon="el-icon-search" onClick={() => this.selectOutNo()} />
          //   </div>
          // );
          // }
        },
        {
          type: 'INPUT',
          label: '救援单号',
          fieldName: 'outNo',
          placeholder: '请输入救援单号...',
          initialValue: undefined,
          readonly: true,
          // disabled: true,
          unitRender: p => {
            return (
              <div>
                <multiuse-button type="primary" icon="el-icon-document" onClick={() => this.detail()}></multiuse-button>
            </div>
          );
          }
        },
        {
          type: 'INPUT',
          label: '自费工单号',
          fieldName: 'selfNo',
          placeholder: '请输入数量...',
          initialValue: undefined,
          readonly: true,
          disabled: true,
          // unitRender: p => {
          //   return (
          //     <div>
          //     <multiuse-button icon="el-icon-search" onClick={() => this.selectselfNo()} />
          //   </div>
          // );
          // }
        },
        {
          type: 'DATE',
          label: '自费配件销售日期',
          fieldName: 'selfSdate',
          placeholder: '请输入数量...',
          valueFormat:'yyyy-MM-DD HH:mm:ss',
          initialValue: undefined,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '自费配件销售里程',
          fieldName: 'selfUseMile',
          placeholder: '请输入数量...',
          initialValue: undefined,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '自费配件使用时长',
          fieldName: 'selfUseHours',
          placeholder: '请输入数量...',
          initialValue: undefined,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '自费配件使用里程',
          fieldName: 'selfMile',
          placeholder: '请输入数量...',
          initialValue: undefined,
          disabled: true,
        },
        {
          type: 'TEXT_AREA',
          label: '故障现象',
          fieldName: 'faultAppear',
          placeholder: '故障现象',
          rows: 3,
          disabled: true,
          selfCols: 4 // 元素占据几行
        },
        {
          type: 'TEXT_AREA',
          label: '故障原因',
          fieldName: 'faultReason',
          placeholder: '故障原因',
          rows: 3,
          disabled: true,
          selfCols: 4 // 元素占据几行
        },
        {
          type: 'TEXT_AREA',
          label: '维修方案',
          fieldName: 'cmsClaimPgm',
          placeholder: '维修方案',
          rows: 3,
          disabled: true,
          selfCols: 4 // 元素占据几行
        },
        {
          type: 'BREAK_SPACE',
          label: '附件'
        },
        {
          type: 'UPLOAD_IMG',
          label: 'VIN',
          fieldName: 'wayPicture',
          placeholder: '上传身份证...',
          selfCols: 1,
          initialValue: [],
          disabled: true,
          upload: {
            actionUrl: '/api/file/oss/upload',
            fixedSize: [5, 3],
            limit: 1,
            isCalcHeight: true,
            isFileName:true,
          }
        },
        {
          type: 'UPLOAD_IMG',
          label: '里程（仪表）',
          fieldName: 'wayPicture1',
          placeholder: '上传身份证...',
          selfCols: 1,
          initialValue: [],
          disabled: true,
          upload: {
            actionUrl: '/api/file/oss/upload',
            fixedSize: [5, 3],
            limit: 1,
            isCalcHeight: true,
            isFileName:true,
          }
        },
        {
          type: 'UPLOAD_IMG',
          label: '车牌（车头）',
          fieldName: 'wayPicture2',
          placeholder: '上传身份证...',
          offsetRightCols: 1,
          initialValue: [],
          disabled: true,
          upload: {
            actionUrl: '/api/file/oss/upload',
            fixedSize: [5, 3],
            limit: 1,
            isCalcHeight: true,
            isFileName:true,
          }
        },
        {
          type: 'UPLOAD_IMG',
          label: '行驶证',
          fieldName: 'wayPicture3',
          placeholder: '上传身份证...',
          selfCols: 1,
          initialValue: [],
          disabled: true,
          upload: {
            actionUrl: '/api/file/oss/upload',
            fixedSize: [5, 3],
            limit: 1,
            isCalcHeight: true,
            isFileName:true,
          }
        },
        {
          type: 'UPLOAD_IMG',
          label: '故障照片',
          fieldName: 'wayPicture4',
          placeholder: '上传身份证...',
          initialValue: [],
          disabled: true,
          selfCols: 1,
          upload: {
            actionUrl: '/api/file/oss/upload',
            fixedSize: [5, 3],
            limit: 1,
            isCalcHeight: true,
            isFileName:true,
          }
        },
        {
          type: 'UPLOAD_IMG',
          label: '故障照片',
          fieldName: 'wayPicture5',
          placeholder: '上传身份证...',
          selfCols: 1,
          initialValue: [],
          disabled: true,
          upload: {
            actionUrl: '/api/file/oss/upload',
            fixedSize: [5, 3],
            limit: 1,
            isCalcHeight: true,
            isFileName:true,
          }
        }
      ];
    },
    createdTable() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          fixed: 'left',
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        // {
        //   title: '操作',
        //   dataIndex: 'column-action',
        //   width: 90,
        //   render: (props, h) => {
        //     return (
        //       <div>
        //         <el-button size="mini" type="text" onClick={() => this.video(props.row)}>
        //           预览
        //         </el-button>
        //       </div>
        //     );
        //   }
        // },
        {
          title: '附件标题',
          dataIndex: 'title',
          showOverflowTooltip: true,
          render: p => {
            return (
              <a style="color:#bb0a30" href={p.row.fileUrl} target="_blank" download={p.row.title}>
                {p.row.title}
              </a>
            );
          }
        },
        {
          title: '上传日期',
          dataIndex: 'createdAt'
        },
      ];
    },
    //维修项目列表
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '维修项目代码', dataIndex: 'labourCode', sorter: true },
        { title: '维修项目名称', dataIndex: 'labourName', sorter: true },
        { title: '维修类型', dataIndex: 'cmsClaimType', sorter: true },
        { title: '标准工时', dataIndex: 'labourHours', sorter: true },
        { title: '索赔工时单价', dataIndex: 'cmsClaimPrice', sorter: true },
        { title: '申请金额', dataIndex: 'cmsClaimAmount', sorter: true },
        { title: '审核金额', dataIndex: 'checkAmount', editable: true,sorter: true ,editType: 'number',
          editValidator:(val, row, callback) => {
            if(row.checkAmount>=0){
              if (row.checkAmount > row.cmsClaimAmount) {
                this.$notify.error({ title: '提示信息', message: '已超过审核金额(' + row.cmsClaimAmount + ')' || '操作失败!' });
                row.checkAmount = row.cmsClaimAmount
                this.changeCells();
              }
            }else{
              this.$notify.error({ title: '提示信息', message: '审核金额不能为负数' || '操作失败!' });
              row.checkAmount = row.cmsClaimAmount
              this.changeCells();
            }

          }
        }
      ];
    },
    //配件换上件列表
    creatHeader1() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '配件代码', dataIndex: 'partCode', sorter: true },
        { title: '配件名称', dataIndex: 'partName', sorter: true },
        { title: '单位', dataIndex: 'partUnit', sorter: true },
        { title: '数量', dataIndex: 'partCount', sorter: true },
        { title: '索赔单价', dataIndex: 'cmsClaimPrice', sorter: true },
        { title: '索赔总价', dataIndex: 'cmsClaimAmount', sorter: true },
        { title: '调整后金额', dataIndex: 'checkAmount', editable: true,sorter: true,editType: 'number',
          editValidator:(val, row, callback) => {
            if(row.checkAmount>=0){
              if (row.checkAmount > row.cmsClaimAmount) {
                this.$notify.error({ title: '提示信息', message: '已超过索赔总价(' + row.cmsClaimAmount + ')' || '操作失败!' });
                row.checkAmount = row.cmsClaimAmount
                this.changeCells1();
              }
            }else{
              this.$notify.error({ title: '提示信息', message: '调整后金额不能为负数' || '操作失败!' });
              row.checkAmount = row.cmsClaimAmount
              this.changeCells1();
            }

          }
          },
      ];
    },
    //换下件
    columnshuanxiajian1() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '配件代码', dataIndex: 'partCode', sorter: true },
        { title: '配件名称', dataIndex: 'partName', sorter: true },
        { title: '单位', dataIndex: 'partUnit', sorter: true },
        { title: '数量', dataIndex: 'partCount', sorter: true },
        { title: '配件回运类型', dataIndex: 'returnType', sorter: true,dictItems:this.createDictList('5585') },
        // { title: '是否电池', dataIndex: 'ifEv', sorter: true },
        // { title: '电池编号', dataIndex: 'evNo', sorter: true }
      ];
    },
    //附加项目
    columnsfujiaxiangmu1() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 80,
          render: props => {
            return (
              <div style="text-align:center">
                <multiuse-button type="text" onClick={() => this.editFile(props.row)} >
                  上传附件
                </multiuse-button>
              </div>
            );
          }
        },
        { title: '附加项目代码', dataIndex: 'addCode', sorter: true },
        { title: '附加项目名称', dataIndex: 'addName', sorter: true },
        { title: '申请金额', dataIndex: 'addAmount', sorter: true },
        { title: '审核金额', dataIndex: 'checkAmount',editable: true, sorter: true,editType: 'number',
          editValidator:(val, row, callback) => {
            if(row.checkAmount>=0){
              if (row.checkAmount > row.addAmount) {
                this.$notify.error({ title: '提示信息', message: '已超过申请金额(' + row.addAmount + ')' || '操作失败!' });
                row.checkAmount = row.addAmount
                this.changeCells3();
              }
            }else{
              this.$notify.error({ title: '提示信息', message: '审核金额不能为负数' || '操作失败!' });
              row.checkAmount = row.addAmount
              this.changeCells3();
            }

          }
        },
        { title: '备注', dataIndex: 'remarks', sorter: true }
      ];
    },
    //申请费用信息
    feiyongformList1() {
      return [
        {
          type: 'INPUT',
          label: '合计费用',
          fieldName: 'sumAmount',
          initialValue: 0,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '工时费用',
          fieldName: 'labourAmount',
          initialValue: 0,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '配件费用',
          fieldName: 'partAmount',
          initialValue: 0,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '附加项目费用',
          fieldName: 'addAmount',
          initialValue: 0,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '外出救援费用',
          fieldName: 'helpAmount',
          initialValue: 0,
          disabled: true,
          readonly: true // 只读
        }
      ];
    }, //审核费用信息
    shenhefeiyongformList1() {
      return [
        {
          type: 'INPUT',
          label: '合计费用',
          fieldName: 'claimSumAmount',
          initialValue: 0,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '工时费用',
          fieldName: 'claimLabourAmount',
          initialValue: 0,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '配件费用',
          fieldName: 'claimPartAmount',
          initialValue: 0,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '附加项目费用',
          fieldName: 'claimAddAmount',
          initialValue: 0,
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '外出救援费用',
          fieldName: 'helpAmount',
          initialValue: 0,
          disabled: true,
          readonly: true // 只读
        },
        {
          type: 'BREAK_SPACE',
          label: '一口价区域',
          style: {}
        },
        {
          type: 'INPUT',
          label: '一口价费用',
          fieldName: 'priceAmount',
          initialValue: '',
          readonly: true // 只读
        },
      ];
    },
    //审核说明
    formListbeizhuform() {
      return [
        {
          type: 'TEXT_AREA',
          label: '审核说明',
          fieldName: 'title',
          placeholder: '请输入标题名称...',
          row:3
          // rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]
        }
      ];
    }
  }
};
</script>

<style lang="less" scoped></style>
